home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / E-G / Get DA Names.cpt / Get DA Names / card_3880.txt < prev    next >
Text File  |  1989-02-26  |  10KB  |  334 lines

  1. -- card: 3880 from stack: in
  2. -- bmap block id: 4900
  3. -- flags: 0000
  4. -- background id: 2777
  5. -- name: Play with Get DA Names
  6. ----- HyperTalk script -----
  7. on openCard
  8.   put empty into card field "Button ID"
  9.   hide card field "Button ID"
  10. end openCard
  11.  
  12. on closeCard
  13.  
  14.   -- If there is already a DA-launching button on this card,
  15.   -- then delete it
  16.   if card field "Button ID" is not empty and the number of card buttons > 5 then
  17.     set cursor to 4
  18.     set lockScreen to true
  19.     put item 1 of card field "Button ID" into buttonID
  20.     choose button tool
  21.     click at the loc of card button ID buttonID
  22.     doMenu "Clear button"
  23.     choose browse tool
  24.     put empty into card field "Button ID"
  25.     set lockScreen to false
  26.   end if
  27.  
  28. end closeCard
  29.  
  30.  
  31. -- part 2 (button)
  32. -- low flags: 00
  33. -- high flags: 8004
  34. -- rect: left=14 top=107 right=129 bottom=182
  35. -- title width / last selected line: 0
  36. -- icon id / first selected line: 0 / 0
  37. -- text alignment: 1
  38. -- font id: 0
  39. -- text size: 12
  40. -- style flags: 0
  41. -- line height: 16
  42. -- part name: Make a button for a DA
  43. ----- HyperTalk script -----
  44. on mouseUp
  45.  
  46.   -- Display the watch cursor
  47.   set cursor to 4
  48.  
  49.   --  Get the names of the DAs, putting these into the container
  50.   --  "namesOfDAs" in item list format
  51.   getDANames
  52.  
  53.   --  Ask for the name of a desk accessory
  54.   --  See James L. Paul's "HyperList" stack for more
  55.   --  information about the DoList command
  56.   DoList "Select","Cancel",namesOfDAs,one
  57.  
  58.   --  If a choice was made, then put the name of the item chosen
  59.   --  into a temporary variable; otherwise exit this script
  60.   if the result > 0 then
  61.     put item 2 of the result into daName
  62.   else
  63.     exit mouseUp
  64.   end if
  65.  
  66.   --  "Freeze" the screen while a button is being made and displayed
  67.   set lockScreen to true
  68.  
  69.   --  If there is already a DA-launching button on this card,
  70.   --  then delete it
  71.   if card field "Button ID" is not empty and the number of card buttons > 5 then
  72.     put item 1 of card field "Button ID" into buttonID
  73.     choose button tool
  74.     click at the loc of card button ID buttonID
  75.     doMenu "Clear button"
  76.     choose browse tool
  77.   end if
  78.  
  79.   --  Make the new button
  80.   doMenu "New Button"
  81.   hide button "New Button"
  82.   put daName into nameOfButton
  83.   set name of button "New Button" to nameOfButton
  84.   --  Use the suitcase icon for DAs which has been pasted into
  85.   --  this stack, and given the name "DA suitcase"
  86.   set icon of button nameOfButton to "DA suitcase"
  87.   set style of button nameOfButton to shadow
  88.   put 50 into leftSide
  89.   put 140 into topSide
  90.   set rect of button nameOfButton to leftSide, topSide, leftSide + 100, topSide + 50
  91.  
  92.   --  Store the button ID of the newly-created button, so
  93.   --  that it can be deleted later
  94.   put ID of button nameOfButton into card field "Button ID"
  95.  
  96.   --  Construct the script for the new button and place it
  97.   --  into the button's script
  98.   put "on mouseUp" & return into buttonScript
  99.   put "doMenu" && quote & daName & quote & Return after buttonScript
  100.   put "end mouseUp" & Return after buttonScript
  101.   set script of button nameOfButton to buttonScript
  102.  
  103.   --  Clean up things and flash the newly-created button
  104.   show button nameOfButton
  105.   choose browse tool
  106.   set lockScreen to false
  107.   repeat 2
  108.     set the hilite of button nameOfButton to true
  109.     set the hilite of button nameOfButton to false
  110.   end repeat
  111.  
  112. end mouseUp
  113.  
  114.  
  115.  
  116. -- part 3 (button)
  117. -- low flags: 00
  118. -- high flags: 8004
  119. -- rect: left=12 top=65 right=86 bottom=182
  120. -- title width / last selected line: 0
  121. -- icon id / first selected line: 0 / 0
  122. -- text alignment: 1
  123. -- font id: 0
  124. -- text size: 12
  125. -- style flags: 0
  126. -- line height: 16
  127. -- part name: Launch a DA
  128. ----- HyperTalk script -----
  129. on mouseUp
  130.  
  131.   set cursor to 4
  132.  
  133.   -- Put the list of the names of the DAs in the apple menu into
  134.   -- the container, "namesOfDAs"
  135.   GetDANames
  136.  
  137.   -- Use James L. Paul's DoList (ListManager) routine to display a list
  138.   -- of DAs, from which one can select a DA to launch
  139.   DoList "Select","Cancel",namesOfDAs,one
  140.  
  141.   if the result is not empty then
  142.     put item 2 of the result into DAToOpen
  143.     doMenu DAToOpen
  144.   end if
  145.  
  146. end mouseUp
  147.  
  148.  
  149.  
  150. -- part 14 (field)
  151. -- low flags: 81
  152. -- high flags: 0000
  153. -- rect: left=16 top=285 right=302 bottom=86
  154. -- title width / last selected line: 0
  155. -- icon id / first selected line: 0 / 0
  156. -- text alignment: 0
  157. -- font id: 3
  158. -- text size: 12
  159. -- style flags: 0
  160. -- line height: 16
  161. -- part name: Button ID
  162.  
  163.  
  164. -- part 26 (button)
  165. -- low flags: 00
  166. -- high flags: 8004
  167. -- rect: left=14 top=220 right=242 bottom=182
  168. -- title width / last selected line: 0
  169. -- icon id / first selected line: 0 / 0
  170. -- text alignment: 1
  171. -- font id: 0
  172. -- text size: 12
  173. -- style flags: 0
  174. -- line height: 16
  175. -- part name: Copy numberOfDAs XFCN
  176. ----- HyperTalk script -----
  177. on mouseUp  --DO NOT CHANGE LINE 2! IT IS MODIFIED BY ANOTHER SCRIPT!
  178.   put "HD20:HyperCard:Example stacks:Get DA Names" into sourceStack
  179.   put the long name of this stack into destStack
  180.   delete first word of destStack
  181.   delete first character of destStack
  182.   delete last character of destStack
  183.   if sourceStack<>destStack then
  184.     set lockscreen to true
  185.     set lockmessages to true
  186.     push this card
  187.     go stack sourceStack
  188.     ResCopy sourceStack,destStack,"XFCN","numberOfDAs"
  189.     get the result
  190.     -- here is where you would copy more resources.
  191.     pop card
  192.     choose button tool
  193.     click at location of card button "Copy numberOfDAs XFCN"
  194.     domenu clear button
  195.     choose browse tool
  196.     set lockmessages to false
  197.     set lockscreen to false
  198.     if first char of it is "E" then
  199.       put char 4 of it into errorNumber
  200.       errorMessage errorNumber -- defined below
  201.     else
  202.       answer "Resource copied successfully to this stack." with "OK"
  203.     end if
  204.   end if
  205. end mouseUp
  206.  
  207. on errorMessage errorNumber
  208.   if errorNumber = 1 then
  209.     answer "The wrong number of parameters were passed." with "OK"
  210.   else if errorNumber = 2 then
  211.     answer "The source file couldn't be opened." with "OK"
  212.   else if errorNumber = 3 then
  213.     answer "A new destination file couldn't be created." with "OK"
  214.   else if errorNumber = 4 then
  215.     answer "The resource to be copied wasn't found in the source." with "OK"
  216.   end if
  217. end errorMessage
  218.  
  219.  
  220.  
  221.  
  222. -- part 27 (button)
  223. -- low flags: 00
  224. -- high flags: 8004
  225. -- rect: left=14 top=246 right=268 bottom=182
  226. -- title width / last selected line: 0
  227. -- icon id / first selected line: 0 / 0
  228. -- text alignment: 1
  229. -- font id: 0
  230. -- text size: 12
  231. -- style flags: 0
  232. -- line height: 16
  233. -- part name: Copy GetDANames XCMD
  234. ----- HyperTalk script -----
  235. on mouseUp  --DO NOT CHANGE LINE 2! IT IS MODIFIED BY ANOTHER SCRIPT!
  236.   put "HD20:HyperCard:Example stacks:Get DA Names" into sourceStack
  237.   put the long name of this stack into destStack
  238.   delete first word of destStack
  239.   delete first character of destStack
  240.   delete last character of destStack
  241.   if sourceStack<>destStack then
  242.     set lockscreen to true
  243.     set lockmessages to true
  244.     push this card
  245.     go stack sourceStack
  246.     ResCopy sourceStack,destStack,"XCMD","GetDANames"
  247.     get the result
  248.     -- here is where you would copy more resources.
  249.     pop card
  250.     choose button tool
  251.     click at location of card button "Copy GetDANames XCMD"
  252.     domenu clear button
  253.     choose browse tool
  254.     set lockmessages to false
  255.     set lockscreen to false
  256.     if first char of it is "E" then
  257.       put char 4 of it into errorNumber
  258.       errorMessage errorNumber -- defined below
  259.     else
  260.       answer "Resource copied successfully to this stack." with "OK"
  261.     end if
  262.   end if
  263. end mouseUp
  264.  
  265. on errorMessage errorNumber
  266.   if errorNumber = 1 then
  267.     answer "The wrong number of parameters were passed." with "OK"
  268.   else if errorNumber = 2 then
  269.     answer "The source file couldn't be opened." with "OK"
  270.   else if errorNumber = 3 then
  271.     answer "A new destination file couldn't be created." with "OK"
  272.   else if errorNumber = 4 then
  273.     answer "The resource to be copied wasn't found in the source." with "OK"
  274.   end if
  275. end errorMessage
  276.  
  277.  
  278.  
  279. -- part 28 (button)
  280. -- low flags: 00
  281. -- high flags: 8004
  282. -- rect: left=14 top=273 right=295 bottom=182
  283. -- title width / last selected line: 0
  284. -- icon id / first selected line: 0 / 0
  285. -- text alignment: 1
  286. -- font id: 0
  287. -- text size: 12
  288. -- style flags: 0
  289. -- line height: 16
  290. -- part name: Copy 'suitcase' icon
  291. ----- HyperTalk script -----
  292. on mouseUp  --DO NOT CHANGE LINE 2! IT IS MODIFIED BY ANOTHER SCRIPT!
  293.   put "HD20:HyperCard:Example stacks:Get DA Names" into sourceStack
  294.   put the long name of this stack into destStack
  295.   delete first word of destStack
  296.   delete first character of destStack
  297.   delete last character of destStack
  298.   if sourceStack<>destStack then
  299.     set lockscreen to true
  300.     set lockmessages to true
  301.     push this card
  302.     go stack sourceStack
  303.     ResCopy sourceStack,destStack,"ICON","DA suitcase"
  304.     get the result
  305.     -- here is where you would copy more resources.
  306.     pop card
  307.     choose button tool
  308.     click at location of card button "Copy 'suitcase' icon"
  309.     domenu clear button
  310.     choose browse tool
  311.     set lockmessages to false
  312.     set lockscreen to false
  313.     if first char of it is "E" then
  314.       put char 4 of it into errorNumber
  315.       errorMessage errorNumber -- defined below
  316.     else
  317.       answer "Resource copied successfully to this stack." with "OK"
  318.     end if
  319.   end if
  320. end mouseUp
  321.  
  322. on errorMessage errorNumber
  323.   if errorNumber = 1 then
  324.     answer "The wrong number of parameters were passed." with "OK"
  325.   else if errorNumber = 2 then
  326.     answer "The source file couldn't be opened." with "OK"
  327.   else if errorNumber = 3 then
  328.     answer "A new destination file couldn't be created." with "OK"
  329.   else if errorNumber = 4 then
  330.     answer "The resource to be copied wasn't found in the source." with "OK"
  331.   end if
  332. end errorMessage
  333.  
  334.